﻿/**
 * jQuery user.base.js
 */
$(function(){
		
	//menu bar
	$J_sysmenu = $('#J_sysmenu');
	$('.menu-wrap dt', $J_sysmenu).toggle(function(){
		var self = $(this);
		self.next().addClass('hide').end().addClass('close');
	}, function(){
		var self = $(this);
		self.next().removeClass('hide').end().removeClass('close');
	});
	
	var $J_rec_search = $('#J_rec_search');
	$('.key_specialty', $J_rec_search).setDefaultText('Keywords');
	$('.key_city', $J_rec_search).setDefaultText('City');
	$('.search_type', $J_rec_search).toggle(function(){
		var self = $(this);
		self.find('.type_list').show();
	},function(e){
		e.stopPropagation();
		var self = $(this);
		self.find('.type_list').hide();				 
	});
	
	$('.type_list>li>a', $J_rec_search).bind('click', function(e){
		e.preventDefault();
		var self = $(this);
		self.parents('.search_type').find('.type_c').text(self.text());
		self.parents('.search_type').find('.type').val(self.attr('name'));
	});
	
	$('.btn_submit', $J_rec_search).click(function(e){
		e.preventDefault();
		var self = $(this);
		var key_specialty = $('.key_specialty', $J_rec_search).val(),
			key_specialtyDefaultval = $('.key_specialty', $J_rec_search)[0].defaultValue,
			key_city = $('.key_city', $J_rec_search).val(),
			key_cityDefaultval = $('.key_city', $J_rec_search)[0].defaultValue;
		if(key_specialty == '' || key_specialty == key_specialtyDefaultval){
			alert('Please check your Keywords, try again!')
		} else if(key_city == '' ||  key_city == key_cityDefaultval){
			alert('Please check your user City, try again!')
		} else {
			self.parents('form').submit();
		}
	});
	
	//view job
	$job_detais_wrapper = $('#job_detais_wrapper');
	$('.viewmore', $job_detais_wrapper).toggle(function(e){
		e.preventDefault();
		var self = $(this);
		self.text('See less')
		self.parents('.wrap').find('.job_fields:eq(1)').show();
	}, function(e){
		e.preventDefault();
		var self = $(this);
		self.text('See more')
		self.parents('.wrap').find('.job_fields:eq(1)').hide();
	});
	
	//ppwindow for upgrading 
	$(".upgrade1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

});


